package com.fling.tutorial;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.NinePatch;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.fling.Locator;
import com.fling.observer.Subject;

public class TapState extends TutorialState{

    private boolean tapped;
    
	public TapState(TutorialManager t, Subject subject){
		super(t,subject);
	}
	
	@Override
	public void update(float delta) {
		if(tapped){
		    timer+=delta;
		    if(timer > 1){
		        exit();
		    }
		}
	}

	@Override
	public void registerInput(INPUT input) {
		switch(input){
		case CLIMB:
			tapped=true;
			break;
		default:
			break;
		}
	}

	@Override
	public void enter() {
	    Locator.setOverallGameSpeed(1);
		Locator.useDifficultySpeed();
	}

	@Override
	public void exit() {
		tutorial.changeState(new FlingState(tutorial, subject));
	}
	
	@Override
	public void render(SpriteBatch sb, NinePatch patch, BitmapFont font) {
	    patch.draw(sb, Gdx.graphics.getWidth() * 0.225f, Gdx.graphics.getHeight() * 0.6f, Gdx.graphics.getWidth() * 0.55f, Gdx.graphics.getHeight() * 0.15f);
        font.drawWrapped(sb, "Hold to keep from \nfalling", Gdx.graphics.getWidth() * 0.25f, Gdx.graphics.getHeight() * 0.71f,Gdx.graphics.getHeight() * 0.32f);
	}

}
